How to run wandb offline
- Create a python environment.
- Activate python environment with wandb.
- Install wandb library
pip install --no-index wandb. - Run
wandb loginto set up your login key. Follow the prompt and paste your api keys (can be found in user settings). - Add
export WANDB_MODE="offline"beforepythonoraccelarate launchline in the shell script. - To run wandb offline with your python script, add
os.environ["WANDB_MODE"]="offline"to your py script. - Input your project name and run name in
wandb.init(). For an example,wandb.init( project='wandbtest', name='test', entity='lence_ubc',) - Use
wandb.log()to log your metrics. For an example,wandb.log({"loss": loss}) - Run your your python script. When your script is done, your logs will be stored inside a new folder
./wandb/offline-run...located in the same directory as your python script. - In the terminal, run
wandb initin your directory to set the project name. - Run
wandb sync ./wandb/offline-run*to push all the saved metrics to the cloud service.
NOTE If you run your code on SLURM_TMPDIR, you will need to zip the wandb folder zip -qr wandb.zip ./wandb and copy it to the project space before doing the last two steps.